package com.lc.afbx.adapters;

import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.TextView;

import com.lc.afbx.BaseApplication;
import com.lc.afbx.R;
import com.lc.afbx.activity.CommissionWithdrawActivity;
import com.lc.afbx.conn.GetApiCommissionExtract;
import com.lc.afbx.util.PrefrenceConfig;
import com.zcx.helper.util.UtilLog;

import java.util.List;

/**
 * Created by Administrator on 2016/6/7.
 */
public class YongJinAdapter extends BaseAdapter {
    private List<GetApiCommissionExtract.Data> dataList;
    private LayoutInflater inflater;
    private Context context;

    public YongJinAdapter(Context context, List<GetApiCommissionExtract.Data> dataList) {
        inflater = LayoutInflater.from(context);
        this.dataList = dataList;
        this.context = context;

//        for (int i = 0; i < 3; i++) {
//            this.dataList.addAll(dataList);
//        }
    }

    @Override
    public int getCount() {
        return dataList.size();
    }

    @Override
    public Object getItem(int position) {
        return dataList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {

        ViewHolder holder = null;
        if (convertView == null) {

            convertView = inflater.inflate(R.layout.item_mingxi, null);
            BaseApplication.ScaleScreenHelper.loadView((ViewGroup) convertView);
            holder = new ViewHolder();

            holder.txt_totalPrice = (TextView) convertView.findViewById(R.id.txt_totalPrice);

            holder.txt_keTiXian = (TextView) convertView.findViewById(R.id.txt_keTiXian);
            holder.txt_tuiJian = (TextView) convertView.findViewById(R.id.txt_tuiJian);
            holder.txt_product = (TextView) convertView.findViewById(R.id.txt_product);

            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        UtilLog.e("佣金Adapter里", dataList.get(position).client + dataList.get(position).products + "");
        holder.txt_keTiXian.setText(dataList.get(position).price);
        holder.txt_tuiJian.setText(dataList.get(position).client);
        holder.txt_product.setText(dataList.get(position).products);

        holder.txt_totalPrice.setText(dataList.get(position).total);

//        holder.btn_caoZuo.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//
//                Intent intent = new Intent(context, CommissionWithdrawActivity.class);
//
//                intent.putExtra(PrefrenceConfig.INTENT_TAG, dataList.get(position).id);
//
//                context.startActivity(intent);
//
////                UtilToast.show(context, "提现还没写啊");
//            }
//        });
        return convertView;
    }

    class ViewHolder {
        TextView txt_keTiXian, txt_tuiJian, txt_product, txt_totalPrice;
    }
}
